package test.tojson;

import java.io.FileWriter;
import java.io.IOException;

import org.apache.solr.common.SolrDocumentList;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

public class FileOutput {

	public static void main(String[] arg) {
		Tojson tjson = new Tojson();
		JSONArray jArray = new JSONArray();
		SolrDocumentList sdl = tjson.GetSlist();
		
		for (int i = 0; i < sdl.size(); i++) {
			
			JSONObject json = new JSONObject(sdl.get(i));					
			System.out.println(json.toString());
		}

		
		/*
		while (!sdl.isEmpty()) {
			JSONObject obj = tjson.GetJson();
			obj.put("tstamp", "asdf");
			obj.put("_version_", "asdf");
			obj.put("segment", "asdf");
			obj.put("host", "asdf");
			obj.put("digest", "asdf");
			obj.put("boost", "asdf");
			obj.put("id", "asdf");
			obj.put("title", "asdf");
			obj.put("content", "asdf");
			obj.put("url", "asdf");

			jArray.add(obj);
		}

		FileWriter file;
		try {
			file = new FileWriter(
					"/var/lib/tomcat7/webapps/jsp_ex/namecard.json");
			file.write(jArray.toJSONString());
			file.flush();
			file.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/

	}
}
